package com.luzhikun.servlet_1;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * ClassName: OneServlet
 * Description:
 * date: 2021/4/15 16:34
 *
 * @author luzhikun
 * @since JDK 1.8
 * <p>
 * 抽象类的作用：
 * 降低接口实现类的难度，当有些方法不需要使用抽象方法时，
 * 交给抽象类来完成，这样接口实现类只需要重写自己需要的方法
 * <p>
 * <p>
 * servlet接口：
 * <p>
 * init
 * getServletConfig
 * getServletInfo
 * Destory-----四个方法对于Servlet接口的实现类没用
 * <p>
 * Tomcat根据Servlet规范调用Servlet接口实现类的规则
 * 1.tomcat有权创建Servlet接口实现类实例对象
 * Servlet ser=new OneServlet();
 * 2.Tomcat根据实例对象调用Servlet方法处理当前
 * 请求 ser.service();
 */
public class OneServlet extends HttpServlet {

//    @Override
//    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
//        super.service(req, res);
//    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("OneServlet针对浏览器发送Get请求处理方式");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("OneServlet针对浏览器发送POST请求处理方式");
    }
}
